package 第二轮工作.西安邮电大学;

import com.alibaba.excel.EasyExcel;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import 青岛大学.QDuBean;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class XAu {
    public static void main(String[] args) throws IOException {
        XAuBean xAuBean = null;
        List<XAuBean> xAuBeans = new ArrayList<>();
        String Url = "http://www.xiyou.edu.cn/szdw2/szdw1.htm#sz2407";
        Connection connect = Jsoup.connect(Url);
        Document post = connect.post();
        for (Element szjs1 : post.getElementsByClass("szjs1")) {
            for (Element element : szjs1.getElementsByTag("li")) {
                xAuBean = new XAuBean();
                xAuBean.setT_name(element.text());
//                System.out.println(element.text());
                String text = element.getElementsByTag("a").attr("href");
//                System.out.println(text);
                String substring = text.substring(2, text.length());
                Connection connect1 = Jsoup.connect("http://www.xiyou.edu.cn" + substring);
                Document post1 = connect1.post();
                String text1 = post1.getElementsByTag("p").text();
                if (text1.length() < 60) {

                } else {
//                    System.out.println(text1);
                    xAuBean.setInfo(text1);
                }
                xAuBeans.add(xAuBean);
            }
        }
        EasyExcel.write("src/XAu.xlsx", XAuBean.class).sheet("user").doWrite(xAuBeans);


    }
}
